package system

main = allow

default allow = false

allow {
    input.method = "GET"
    input.path = ["api", "project", project_id, "person"]
}

allow {
    input.method = "POST"
    input.path = ["api", "project", project_id, "person"]
}

allow {
    input.method = "DELETE"
    input.path = ["api", "project", project_id, "person", person_id]
}

allow {
    input.method = "GET"
    input.path = ["api", "project", "undone_person"]
}

allow {
    input.method = "GET"
    input.path = ["api", "user-info"]
}

allow {
    input.method = "POST"
    input.path = ["api", "project", project_id, "update_status"]
}

allow {
    input.method = "POST"
    input.path = ["api", "user", "status"]
}

allow {
    input.method = "GET"
    input.path = ["api", "user_cabinet"]
}

allow {
    input.method = "POST"
    input.path = ["api", "project"]
}

allow {
    input.method = "GET"
    input.path = ["api", "project"]
    has_role("car_admin")
}

allow {
    input.method = "PUT"
    input.path = ["api", "project", project_id]
}

allow {
    input.method = "DELETE"
    input.path = ["api", "project", project_id]
}

allow {
    input.method = "GET"
    input.path = ["api", "project_date"]
}

allow {
    input.method = "POST"
    input.path = ["api", "pdf", "import"]
}

allow {
    input.method = "POST"
    input.path = ["api", "pdf", "parse"]
}

allow {
    input.method = "POST"
    input.path = ["api", "picture", "check"]
}

allow {
    input.method = "POST"
    input.path = ["api", "resource", "personInfo"]
}

allow {
    input.method = "POST"
    input.path = ["api", "visitor", "appointment"]
}

allow {
    input.method = "POST"
    input.path = ["api", "person", "single", "add"]
}

allow {
    input.method = "POST"
    input.path = ["api", "visitor", "order", "register"]
}

allow {
    input.method = "POST"
    input.path = ["api", "visitor", "out"]
}

allow {
    input.method = "POST"
    input.path = ["api", "cabinet", "lockSpace"]
}

allow {
    input.method = "POST"
    input.path = ["api", "cabinet", "unlockSpace"]
}

allow {
    input.method = "POST"
    input.path = ["api", "cabinet", "openSpace"]
}

has_role(name) {
    employee := employees[input.user]
    employee.roles[name]
}

employees = {
    "alice": {"roles": {"manager", "car_admin"}},
    "james": {"roles": {"manager"}},
    "kelly": {"roles": {"car_admin"}},
}